package com.lcm.oj.lanqiao.year2021.moni.c2;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

/**
 * @author Coder-lcm
 * @date 2021/4/17
 */
public class T9 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int t = sc.nextInt();
        int[][] bfs = new int[n][m];
        // BFS关键，判断该点是否已经走过了
        int[][] visited = new int[n][m];
        Queue<ProcessPoint> queue = new LinkedList<ProcessPoint>();
        for (int i = 0; i < t; i++) {
            int tx = sc.nextInt();
            int ty = sc.nextInt();
            bfs[tx-1][ty-1] = 1;
            queue.offer(new ProcessPoint(tx - 1, ty-1));
        }
        int k = sc.nextInt();

        while (queue.size() > 0) {
            if (k-- == 0) {
                break;
            }
            int size = queue.size();
            for (int i = 0; i < size; i++) {
                //正在扩散的点坐标
                ProcessPoint point = queue.poll();
                int ttx = point.getX();
                int tty = point.getY();
                // 标志该点已经扩散过了，下次不用再扩散了
                visited[ttx][tty] = 1;
                // 向四周扩散
                //上方
                if (ttx - 1 >= 0) {
                    //灌水标志
                    bfs[ttx-1][tty] = 1;
                    //若还没扩散该点，则加入待扩散队列
                    if (visited[ttx-1][tty] == 0) {
                        queue.offer(new ProcessPoint(ttx-1, tty));
                    }
                }

                //下方
                if (ttx + 1 < n) {
                    //灌水标志
                    bfs[ttx+1][tty] = 1;
                    //若还没扩散该点，则加入待扩散队列
                    if (visited[ttx+1][tty] == 0) {
                        queue.offer(new ProcessPoint(ttx+1, tty));
                    }
                }

                //左方
                if (tty - 1 >= 0) {
                    bfs[ttx][tty-1] = 1;
                    if (visited[ttx][tty-1] == 0) {
                        queue.offer(new ProcessPoint(ttx, tty-1));
                    }
                }

                //右方
                if (tty + 1 < m) {
                    bfs[ttx][tty+1] = 1;
                    if (visited[ttx][tty+1] == 0) {
                        queue.offer(new ProcessPoint(ttx, tty+1));
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            for (int i1 = 0; i1 < m; i1++) {
                System.out.print(bfs[i][i1] +" ");
            }
            System.out.println();
        }

    }
}
// 即将要扩散的点
class ProcessPoint{
    int x;
    int y;

    public ProcessPoint(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}